﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

//网络管理类
public class NetWorkManager{
    public enum UrlType{
        Center,
        Server,
    }
    private string serverUrl = "http://119.29.166.152:82/RenXin/index.php/ajaxgateway/index";
    private string centerUrl = "http://119.29.166.152:82/RenXin/index.php/ajaxgateway/index";
    private static NetWorkManager instance;
    public static NetWorkManager Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new NetWorkManager();
            }
            return instance;
        }
    }
    private NetWorkManager()
    {

    }
    /// <summary>
    /// 获得请求参数模板
    /// </summary>
    /// <param name="action"></param>
    /// <param name="method"></param>
    /// <returns></returns>
    public Dictionary<string, object> GetData(string action, string method)
    {
        Dictionary<string, object> data = new Dictionary<string, object>();
        data.TryAdd("a", action);
        data.TryAdd("m", method);
        return data;
    }
    /// <summary>
    /// 获得网络对象实例
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public MyNetWork<T> GetNetInstance<T>()
    {
        var net = new MyNetWork<T>();
        return net;
    }
    /// <summary>
    /// 获得网络对象实例
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public MyNetWork<ResultModel> GetNetInstance()
    {
        var net = new MyNetWork<ResultModel>();
        return net;
    }
    /// <summary>
    /// 获取网络地址
    /// </summary>
    /// <returns></returns>
    public string GetUrl(UrlType type = UrlType.Server)
    {
        if (type == UrlType.Center) return centerUrl;
        return serverUrl;
    }
}
